# coding=utf-8
import os
import subprocess

# input_path = r"E:\untitled1\audio_test\input"
# output_path = r"E:\untitled1\audio_test\out"
filepath = "data/speechocean_dev"
Root = "E:/DeepLearning/dl_studio/bishe/my_ch_speech_recognition-master/"
Root2 = "C:/Users/ogj/Desktop/data2/"
fs = 16000
with open(filepath + ".txt", 'r', encoding="utf8") as infile:
    for wav in infile:
        path, pin, han = wav.split("\t")
        print(Root + path)
        inPath = Root + path
        outPath = Root2+path
        if not os.path.exists(outPath[:-13]):
            os.mkdir(outPath[:-13])
        cmd = "ffmpeg -i " + inPath + " -ar " + str(fs) + " " + outPath
        subprocess.call(cmd, shell=True)
# for file in os.listdir(input_path):
#     file1 = input_path + '\\' + file
#     file2 = output_path + '\\' + file
#     cmd = "ffmpeg -i " + file1 + " -ar " + str(fs) + " " + file2  # ffmpeg -i 输入文件 -ar 采样率  输出文件
#     subprocess.call(cmd, shell=True)
print("结束")
